home *** CD-ROM | disk | FTP | other *** search
- /*
- * a header of the class INTSTR_ELEMENT
- * Copyright (C) 1996, 1997 Kazutaka Hirata <khirata@jove.acs.unt.edu>
- */
-
- #ifndef _INTSTR_H_
- #define _INTSTR_H_
-
- #include <string.h>
-
- #include "common/typedef.h"
-
- class INTSTR_ELEMENT {
- public:
- uint no;
- const char* str;
- };
-
- class INTSTR_TABLE {
- const INTSTR_ELEMENT* m_table;
- uint m_last;
- public:
- INTSTR_TABLE(const INTSTR_ELEMENT* table, uint last)
- : m_table(table),
- m_last (last ) {}
- INTSTR_TABLE(void) {}
- const char* get_str(uint no) const {
- for(uint i = 0; m_table[i].no != m_last; i++) {
- const INTSTR_ELEMENT& current = m_table[i];
- if(current.no == no) {
- return current.str;
- }
- }
- return NULL;
- }
- uint get_no(const char* str) const {
- for(uint i = 0; m_table[i].no != m_last; i++) {
- const INTSTR_ELEMENT& current = m_table[i];
- if(!strcmp(current.str, str)) {
- return current.no;
- }
- }
- return m_last;
- }
- };
-
- #endif /* _INTSTR_H_ */
-